import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '首页', icon: 'dashboard' }
    }]
  },
  {
    path:'/employees',
    component: Layout,
    name:'Employees',
    meta: {title: "员工模块" , icon:'el-icon-data-analysis'},
    children:[
      {
        path: '/room',
        name: 'Room',
        component: () => import('@/views/room/index'),
        meta: {title: "房间", icon: 'el-icon-house'},
      },
      {
        path: 'guest',
        name: 'Guest',
        component: () => import('@/views/guest/index'),
        meta: { title: '客户', icon: 'table' }
      },
      {
        path:'housing',
        name:'Housing',
        component:()=> import('@/views/search/index'),
        meta: {title:"入住",icon:'table'},
        name: "search"
      },
      {
        path:'hesuan',
        name:'Hesuan',
        component:() => import('@/views/hesuan/index'),
        meta: {title:'核酸',icon:'table'}
      },
      {
        path:'serve',
        name:'Serve',
        component:() => import('@/views/serve/index'),
        meta: {title:'服务',icon:'table'}
      },
     //employees
    ]
  },
  {
    path:'/geren',
    name:'Geren',
    component: () => import("@/views/guest/geren/index")
  }
  // 404 page must be placed at the end !!!

]

export const asyncRoutes = [

  {
    path:'/manager',
    component: Layout,
    name:'manager',
    meta: {title: "经理管理" , icon:'el-icon-data-analysis'},
    children:[
      {
        path:'roomtype',
        name:'RoomType',
        component: () => import('@/views/roomType/index'),
        meta: {title: '房型管理',icon: 'el-icon-house'}
      },
      {
        path: 'roomManagement',
        name: 'roomManagement',
        component: () => import('@/views/roomManagement/index'),
        meta: {title: "房间管理", icon: 'el-icon-house'},
      },
      {
        path:'employees',
        name:'Employees',
        component: ()=>import('@/views/employees/index'),
        meta: {title: '员工管理',icon:'el-icon-house'}
      },

     //employees
    ]
  },
  {
    path: '/sysUser',
    component: Layout,
    // redirect: '/example/table',
    name: 'sysUser',
    meta: { title: 'Boos module', icon: 'el-icon-s-help' },
    children: [
      {
        path: 'user',
        name: 'User',
        component: () => import('@/views/admin/index'),
        meta: { title: '管理员', icon: 'el-icon-s-custom' }
      },
      // {
      //   path: 'guest',
      //   name: 'Guest',
      //   component: () => import('@/views/guest/index'),
      //   meta: { title: '客户', icon: 'table' }
      // },
      // {
      //   path: '/room',
      //   name: 'Room',
      //   component: () => import('@/views/room/index'),
      //   meta: {title: "房间管理", icon: 'el-icon-house'},
      // }
    ]
  },

]

export const anyRoutes =  { path: '*', redirect: '/404', hidden: true }

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
